/*
* 1videoConference -- An open source video conferencing platform.
*
* Copyright (C) 2007 - 2008, Adiance Technologies Pvt. Ltd.
*
* Hardik Sanghvi <hardik.sanghvi @adiance.com>
*
* See http://www.1videoconference.org for more information about
* the 1videoConference project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, forums and mailing lists
* for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/


using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Globalization;

namespace _videoConference.DAL
{
    public class Database
    {
        SqlParameter[] Params;
        DataSet ds = new DataSet();
        public static string conStr = "";
        int Result = -1;

        public Database()
        {
            //conStr = System.Configuration.ConfigurationManager.AppSettings["ConnString"].ToString();    
            ds.Locale = CultureInfo.InvariantCulture;
        }

        public DataSet FetchGuestName(string mid, string email)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@varMId", SqlDbType.VarChar, 400);
            Params[0].Value = mid;

            Params[1] = new SqlParameter("@varEmail", SqlDbType.VarChar, 400);
            Params[1].Value = email;


            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procFetchGuestName", Params);
                return ds;
            }
            catch (Exception exp)
            {
                ////exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--FetchGuestName()--:--");
                //clsUtility.LogException = exp;
                return new DataSet();

            }
        }

        public DataSet Layoutid()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procLayoutid", null);
                return ds;
            }
            catch
            {
                ////exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--Layoutid()--:--");
                //clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public string AddZipInfo(string modulename, string zipfilename, string location)
        {
            string[] tablename ={ "ar1" };
            Params = new SqlParameter[5];

            Params[0] = new SqlParameter("@varModuleName", SqlDbType.VarChar, int.MaxValue);
            Params[0].Value = modulename;

            Params[1] = new SqlParameter("@varZipFileName", SqlDbType.VarChar, int.MaxValue);
            Params[1].Value = zipfilename;

            Params[2] = new SqlParameter("@varLocation", SqlDbType.VarChar, int.MaxValue);
            Params[2].Value = location;

            Params[3] = new SqlParameter("@varDateTime", SqlDbType.VarChar, int.MaxValue);
            Params[3].Value = DateTime.Now;

            Params[4] = new SqlParameter("@Result", SqlDbType.Int, 5);
            Params[4].Direction = ParameterDirection.Output;

            try
            {
                DataSet ds = SqlHelper.ExecuteDataset(conStr, CommandType.StoredProcedure, "procAddZipInfo", Params);
                //SqlHelper.FillDataset(conStr, CommandType.StoredProcedure, "procAddZipInfo",ds, tablename, Params);                

                if (Params[4].Value != DBNull.Value)
                {
                    return Convert.ToString(Params[4].Value);
                }
                else
                {
                    return "-1";
                }
            }
            catch (Exception exp)
            {
                clsException.LogError(exp);
                return "-1";
            }

        }

        public DataSet AddPage(string PageName, string PageTitle, string PageDesc, string Menu)
        {
            Params = new SqlParameter[4];

            Params[0] = new SqlParameter("@varPageName", SqlDbType.VarChar, 400);
            Params[0].Value = PageName;

            Params[1] = new SqlParameter("@varPageTitle", SqlDbType.VarChar, 400);
            Params[1].Value = PageTitle;

            Params[2] = new SqlParameter("@varPageDesc", SqlDbType.VarChar, 400);
            Params[2].Value = PageDesc;

            Params[3] = new SqlParameter("@varMenu", SqlDbType.VarChar, 400);
            Params[3].Value = Menu;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procAddPage", Params);
                return ds;
            }
            catch (Exception exp)
            {
                ////exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--AddPage()--:--");
                //clsUtility.LogException = exp;
                clsException.LogError(exp);
                return new DataSet();
            }
        }

        public DataSet AddModule(string DllName, string ClassName, string ModuleName, string ModuleDesc, string ModuleVersion, string Dllid)
        {
            Params = new SqlParameter[6];

            Params[0] = new SqlParameter("@varDllName", SqlDbType.VarChar, 400);
            Params[0].Value = DllName;

            Params[1] = new SqlParameter("@varClassName", SqlDbType.VarChar, 400);
            Params[1].Value = ClassName;

            Params[2] = new SqlParameter("@varModuleName", SqlDbType.VarChar, 400);
            Params[2].Value = ModuleName;

            Params[3] = new SqlParameter("@varModuleDesc", SqlDbType.VarChar, 400);
            Params[3].Value = ModuleDesc;

            Params[4] = new SqlParameter("@varModuleVersion", SqlDbType.VarChar, 400);
            Params[4].Value = ModuleVersion;

            Params[5] = new SqlParameter("@varDllID", SqlDbType.VarChar, 400);
            Params[5].Value = Dllid;


            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procAddModule", Params);
                return ds;
            }
            catch (Exception exp)
            {
                ////exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--AddModule()--:--");
                //clsUtility.LogException = exp;
                clsException.LogError(exp);
                return new DataSet();
            }

        }

        public bool UdtDllTable(string DllName, string ModID)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@varDllName", SqlDbType.VarChar, 700);
            Params[0].Value = DllName;

            Params[1] = new SqlParameter("@varModID", SqlDbType.VarChar, 700);
            Params[1].Value = ModID;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procDllTable", Params);
                return true;
            }
            catch (Exception exp)
            {
                ////exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--UdtDllTable()--:--");
                //clsUtility.LogException = exp;
                clsException.LogError(exp);
                return false;
            }

        }

        public bool UdtNamespaceTable(string DllName, string NamespaceName, string NamespaceVersion)
        {
            Params = new SqlParameter[3];

            Params[0] = new SqlParameter("@varDName", SqlDbType.VarChar, 700);
            Params[0].Value = DllName;

            Params[1] = new SqlParameter("@varNName", SqlDbType.VarChar, 700);
            Params[1].Value = NamespaceName;

            Params[2] = new SqlParameter("@varNVersion", SqlDbType.VarChar, 700);
            Params[2].Value = NamespaceVersion;


            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procNamespaceTable", Params);
                return true;
            }
            catch (Exception exp)
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--UdtNamespaceTable()--:--");
                clsException.LogError(exp);
                //clsException.LogError(exp);
                //// clsUtility.LogException = exp;
                return false;
            }

        }

        public bool UdtClassTable(string NamespaceName, string ClassName)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@varNName", SqlDbType.VarChar, 700);
            Params[0].Value = NamespaceName;

            Params[1] = new SqlParameter("@varCName", SqlDbType.VarChar, 700);
            Params[1].Value = ClassName;
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procClassTable", Params);
                return true;
            }
            catch (Exception exp)
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--UdtClassTable()--:--");
                //clsUtility.LogException = exp;
                clsException.LogError(exp);
                return false;
            }

        }

        public DataSet GetMenuName()
        {

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procMenuName", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GenMenuName()--:--");
                //clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public bool MenuTable(string MName, string MIName)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@varMenuName", SqlDbType.VarChar, 700);
            Params[0].Value = MName;

            Params[1] = new SqlParameter("@varMenuItemName", SqlDbType.VarChar, 700);
            Params[1].Value = MIName;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procMenuTable", Params);
                return true;
            }
            catch
            {
                //    exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--MenuTable()--:--");
                //   // clsUtility.LogException = exp;
                return false;
            }
        }

        public DataSet GetModuleName()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetModuleName", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetModuleName()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet GetPageName()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetPageName", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetPageName()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();

            }
        }

        public DataSet GetMenuOrder()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetMenu", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetMenuOrder()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet GetOrder()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetOrder", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetOrder()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet GetMaxId()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetMaxId", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetMaxId()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet SaveMenuItem(int i, int j, byte[] a, string str, string pagename)
        {
            Params = new SqlParameter[5];

            Params[0] = new SqlParameter("@id", SqlDbType.Int, 5);
            Params[0].Value = i;

            Params[1] = new SqlParameter("@parid", SqlDbType.Int, 5);
            Params[1].Value = j;

            if (a == null)
            {
                Params[2] = new SqlParameter("@img", SqlDbType.Image, 0);
                Params[2].Value = DBNull.Value;
            }
            else
            {
                Params[2] = new SqlParameter("@img", SqlDbType.Image, a.Length);
                Params[2].Value = a;

            }

            Params[3] = new SqlParameter("@caption", SqlDbType.VarChar, 50);
            Params[3].Value = str;

            Params[4] = new SqlParameter("@page", SqlDbType.VarChar, 50);
            Params[4].Value = pagename;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procSaveItem", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--SaveMenuItem()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet GetChildren(int i)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@id", SqlDbType.Int, 5);
            Params[0].Value = i;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetChildren", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetChildren()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet GetNonParent()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetNonParent", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetNonParent()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public bool DeleteMenu()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procDelMenu", null);
                return true;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--DeleteMenu()--:--");
                // clsUtility.LogException = exp;
                return false;
            }
        }

        public bool UptMenuTable(int id, string pagename)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@id", SqlDbType.Int, 5);
            Params[0].Value = id;

            Params[1] = new SqlParameter("@pagename", SqlDbType.VarChar, 50);
            Params[1].Value = pagename;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procUdtMenuTable", Params);
                return true;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--UdtMenutable()--:--");
                // clsUtility.LogException = exp;
                return false;
            }
        }

        public DataSet SelectLayout()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procSelectLayout", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--SelectLayout()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public bool InsertLayout(string layoutname)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@Name", SqlDbType.Int, 5);
            Params[0].Value = layoutname;

            Params[1] = new SqlParameter("@DateTime", SqlDbType.VarChar, 50);
            Params[1].Value = DateTime.Now;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procInsertLayout", Params);
                return true;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--InsertLayout()--:--");
                // clsUtility.LogException = exp;
                return false;
            }
        }

        public bool InsertPod(string titlename, string controlname, double height, double width, double left, double top, string layoutname,string modid)
        {
            Params = new SqlParameter[8];

            Params[0] = new SqlParameter("@TitleName", SqlDbType.VarChar, 20);
            Params[0].Value = titlename;

            Params[1] = new SqlParameter("@ControlName", SqlDbType.VarChar, 200);
            Params[1].Value = controlname;

            Params[2] = new SqlParameter("@Height", SqlDbType.Float, 10);
            Params[2].Value = height;

            Params[3] = new SqlParameter("@Width", SqlDbType.Float, 10);
            Params[3].Value = width;

            Params[4] = new SqlParameter("@Left", SqlDbType.Float, 10);
            Params[4].Value = left;


            Params[5] = new SqlParameter("@Top", SqlDbType.Float, 10);
            Params[5].Value = top;


            Params[6] = new SqlParameter("@layoutname", SqlDbType.VarChar, 200);
            Params[6].Value = layoutname;

            Params[7] = new SqlParameter("@modid", SqlDbType.VarChar, 50);
            Params[7].Value = modid;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procInsertPod", Params);
                return true;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--InsertPod()--:--");
                // clsUtility.LogException = exp;
                return false;
            }

        }

        public DataSet SetLayout(string layoutname)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varlayoutname", SqlDbType.VarChar, 20);
            Params[0].Value = layoutname;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procsetlayout", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--setlayout()--:--");
                // clsUtility.LogException = exp;
                return null;
            }

        }

        public DataSet SetPod(int i)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@id", SqlDbType.VarChar, 20);
            Params[0].Value = i;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procsetpod", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--setpod()--:--");
                // clsUtility.LogException = exp;
                return null;
            }
        }

        public bool DeletePod(string layoutname)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@layoutname", SqlDbType.VarChar, 20);
            Params[0].Value = layoutname;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procDeletePod", Params);
                return true;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--DeletePod()--:--");
                // clsUtility.LogException = exp;
                return false;
            }
        }

        public bool DelPodID(string podId)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varpid", SqlDbType.VarChar, 20);
            Params[0].Value = podId;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procDelPodID", Params);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public DataSet GetControlName(string layoutname)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varControlName", SqlDbType.VarChar, 70);
            Params[0].Value = layoutname;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetControlName", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetControlName()--:--");
                // clsUtility.LogException = exp;
                return null;
            }

        }

        public DataSet GetCountry()
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@parFields", SqlDbType.VarChar, 400);
            Params[0].Value = "CountryID,[Country Name]";

            Params[1] = new SqlParameter("@parConditions", SqlDbType.VarChar, 400);
            Params[1].Value = "1=1";
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procCountrySel", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--Countrysel()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet GetState(string s)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@parFields", SqlDbType.VarChar, 400);
            Params[0].Value = "StateID,[State Name]";

            Params[1] = new SqlParameter("@parConditions", SqlDbType.VarChar, 400);
            Params[1].Value = s;
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procStateSel", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--StateSel()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet GetConfig()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetConfig", null);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetConfig()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet UserRegSel(string name, string pass)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@parFields", SqlDbType.VarChar, 400);
            Params[0].Value = "FName, AcceptLicence, Number";

            Params[1] = new SqlParameter("@parConditions", SqlDbType.VarChar, 400);
            Params[1].Value = "EMail='" + name + "'and Pass='" + pass + "'";

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procUserRegSel", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--UserRegSel()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet GuestInfoSel(string name)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@parFields", SqlDbType.VarChar, 400);
            Params[0].Value = "GuestFName, GuestNumber";

            Params[1] = new SqlParameter("@parConditions", SqlDbType.VarChar, 400);
            Params[1].Value = "GuestEMail='" + name + "'";
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGuestInfoSel", Params);
                return ds;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GuestInfoSel()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public bool SetConfig(string smtpserver, string smtpport, string name, string pass, string asteriskserver, string ssl)
        {
            Params = new SqlParameter[6];

            Params[0] = new SqlParameter("@parSMTPServer", SqlDbType.VarChar, 700);
            Params[0].Value = smtpserver;

            Params[1] = new SqlParameter("@parSMTPPort", SqlDbType.VarChar, 700);
            Params[1].Value = smtpport;

            Params[2] = new SqlParameter("@parSMTPUserName", SqlDbType.VarChar, 700);
            Params[2].Value = name;

            Params[3] = new SqlParameter("@parSMTPPassword", SqlDbType.VarChar, 700);
            Params[3].Value = pass;

            Params[4] = new SqlParameter("@parAsteriskServer", SqlDbType.VarChar, 700);
            Params[4].Value = asteriskserver;

            Params[5] = new SqlParameter("@parSMTPSSL", SqlDbType.VarChar, 700);
            Params[5].Value = ssl;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procSetConfig", Params);
                return true;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--SetConfig()--:--");
                // clsUtility.LogException = exp;
                return false;
            }

        }

        public int GuestMeetingInfo(string name, string meetingid)
        {
            string[] tablename ={ "ar1" };
            Params = new SqlParameter[3];

            Params[0] = new SqlParameter("@parGuestmail", SqlDbType.VarChar, 50);
            Params[0].Value = name;

            Params[1] = new SqlParameter("@parGuestMId", SqlDbType.VarChar, 50);
            Params[1].Value = meetingid;

            Params[2] = new SqlParameter("@Result", SqlDbType.Int, 5);
            Params[2].Direction = ParameterDirection.Output;

            try
            {
                DataSet ds = SqlHelper.ExecuteDataset(conStr, CommandType.StoredProcedure, "procGuestMeetingInfo", Params);
                SqlHelper.FillDataset(conStr, CommandType.StoredProcedure, "procGuestMeetingInfo", ds, tablename, Params);

                if (Params[2].Value != DBNull.Value)
                {
                    return Convert.ToInt16(Params[2].Value);
                }
                else
                {
                    return -1;
                }
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GuestMeetingInfo()--:--");
                // clsUtility.LogException = exp;
                return Result;
            }
        }

        public int MeetingInfo(string parUserName, string parPassword, string parmid)
        {
            string[] tablename ={ "ar1" };
            Params = new SqlParameter[4];
            Params[0] = new SqlParameter("@parUserName", SqlDbType.VarChar, 50);
            Params[0].Value = parUserName;

            Params[1] = new SqlParameter("@parPassword", SqlDbType.VarChar, 50);
            Params[1].Value = parPassword;

            Params[2] = new SqlParameter("@parMId", SqlDbType.VarChar, 50);
            Params[2].Value = parmid;

            Params[3] = new SqlParameter("@Result", SqlDbType.Int, 1);
            Params[3].Direction = ParameterDirection.Output;
            try
            {
                DataSet ds = SqlHelper.ExecuteDataset(conStr, CommandType.StoredProcedure, "procMeetingInfo", Params);
                SqlHelper.FillDataset(conStr, CommandType.StoredProcedure, "procMeetingInfo", ds, tablename, Params);

                if (Params[3].Value != DBNull.Value)
                {
                    return Convert.ToInt16(Params[3].Value);
                }
                else
                {
                    return -1;
                }
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--MeetingInfo()--:--");
                // clsUtility.LogException = exp;
                return Result;
            }
        }

        public bool UpdLicense(int parmid)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@parmid", SqlDbType.Int, 20);
            Params[0].Value = parmid;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procUptLicense", Params);
                return true;
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--UptLicense()--:--");
                // clsUtility.LogException = exp;
                return false;
            }

        }

        public int DateCompare(string date, string time)
        {
            int value = 0;
            string[] tablename ={ "ar1" };
            Params = new SqlParameter[3];

            Params[0] = new SqlParameter("@parDate", SqlDbType.VarChar, 50);
            Params[0].Value = date;

            Params[1] = new SqlParameter("@parTime", SqlDbType.VarChar, 50);
            Params[1].Value = time;

            Params[2] = new SqlParameter("@Result", SqlDbType.Int, 5);
            Params[2].Direction = ParameterDirection.Output;

            try
            {
                DataSet ds = SqlHelper.ExecuteDataset(conStr, CommandType.StoredProcedure, "procDateCompare", Params);
                SqlHelper.FillDataset(conStr, CommandType.StoredProcedure, "procDateCompare", ds, tablename, Params);
                if (Params[2].Value != DBNull.Value)
                {
                    return Convert.ToInt16(Params[2].Value);
                }
                else
                {
                    return -1;
                }
            }

            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--DateCompare()--:--");
                // clsUtility.LogException = exp;
                return Result;
            }
        }

        public DataSet GetAccId(string email)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@parEmailacc", SqlDbType.VarChar, 20);
            Params[0].Value = email;


            try
            {

                ds = SqlHelper.ExecuteDataset(conStr, "procGetAccId", Params);
                return ds;
            }
            catch (Exception exp)
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GetAccId()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet InsMeetingInfo(string parUserName, string parPass, string parfname, string parlname, string parcity, string parpincode, string parphone, string parfax, string parMeetingname, string parMeetingDate, string parMeetingStartTime, string parMeetingEndTime, string parcountryid, string parstateid, string parguest1, string parguest1Name, string parguest2, string parguest2Name, string parguest3, string parguest3Name, string parguest4, string parguest4Name, string parguest5, string parguest5Name, string parguest6, string parguest6Name, string paraccId)
        {
            Params = new SqlParameter[27];

            Params[0] = new SqlParameter("@parUserName", SqlDbType.VarChar, 50);
            Params[0].Value = parUserName;

            Params[1] = new SqlParameter("@parPass", SqlDbType.VarChar, 50);
            Params[1].Value = parPass;

            Params[2] = new SqlParameter("@parfname", SqlDbType.VarChar, 50);
            Params[2].Value = parfname;

            Params[3] = new SqlParameter("@parlname", SqlDbType.VarChar, 50);
            Params[3].Value = parlname;

            Params[4] = new SqlParameter("@parcity", SqlDbType.VarChar, 50);
            Params[4].Value = parcity;

            Params[5] = new SqlParameter("@parpincode", SqlDbType.VarChar, 50);
            Params[5].Value = parpincode;

            Params[6] = new SqlParameter("@parphone", SqlDbType.VarChar, 50);
            Params[6].Value = parphone;

            Params[7] = new SqlParameter("@parfax", SqlDbType.VarChar, 50);
            Params[7].Value = parfax;

            Params[8] = new SqlParameter("@parMeetingname", SqlDbType.VarChar, 50);
            Params[8].Value = parMeetingname;

            Params[9] = new SqlParameter("@parMeetingDate", SqlDbType.VarChar, 50);
            Params[9].Value = parMeetingDate;

            Params[10] = new SqlParameter("@parMeetingStartTime", SqlDbType.VarChar, 50);
            Params[10].Value = parMeetingStartTime;

            Params[11] = new SqlParameter("@parMeetingEndTime", SqlDbType.VarChar, 50);
            Params[11].Value = parMeetingEndTime;

            Params[12] = new SqlParameter("@parcountryid", SqlDbType.VarChar, 50);
            Params[12].Value = parcountryid;

            Params[13] = new SqlParameter("@parstateid", SqlDbType.VarChar, 50);
            Params[13].Value = parstateid;

            Params[14] = new SqlParameter("@parguest1", SqlDbType.VarChar, 50);
            Params[14].Value = parguest1;

            Params[15] = new SqlParameter("@parguest1Name", SqlDbType.VarChar, 50);
            Params[15].Value = parguest1Name;

            Params[16] = new SqlParameter("@parguest2", SqlDbType.VarChar, 50);
            Params[16].Value = parguest2;

            Params[17] = new SqlParameter("@parguest2Name", SqlDbType.VarChar, 50);
            Params[17].Value = parguest2Name;

            Params[18] = new SqlParameter("@parguest3", SqlDbType.VarChar, 50);
            Params[18].Value = parguest3;

            Params[19] = new SqlParameter("@parguest3Name", SqlDbType.VarChar, 50);
            Params[19].Value = parguest3Name;

            Params[20] = new SqlParameter("@parguest4", SqlDbType.VarChar, 50);
            Params[20].Value = parguest4;

            Params[21] = new SqlParameter("@parguest4Name", SqlDbType.VarChar, 50);
            Params[21].Value = parguest4Name;

            Params[22] = new SqlParameter("@parguest5", SqlDbType.VarChar, 50);
            Params[22].Value = parguest5;

            Params[23] = new SqlParameter("@parguest5Name", SqlDbType.VarChar, 50);
            Params[23].Value = parguest5Name;

            Params[24] = new SqlParameter("@parguest6", SqlDbType.VarChar, 50);
            Params[24].Value = parguest6;

            Params[25] = new SqlParameter("@parguest6Name", SqlDbType.VarChar, 50);
            Params[25].Value = parguest6Name;

            Params[26] = new SqlParameter("@paraccId", SqlDbType.VarChar, 50);
            Params[26].Value = paraccId;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procInsMeetingInfo", Params);
                return ds;
            }
            catch (Exception exp)
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--InsMeetingInfo()--:--");
                // clsUtility.LogException = exp;
                return new DataSet();
            }
        }

        public DataSet Meetingsel(string id)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@parFields", SqlDbType.VarChar, 400);
            Params[0].Value = "MeetingName, MDate, MTime, MEndTime,AccId";

            Params[1] = new SqlParameter("@parConditions", SqlDbType.VarChar, 400);
            Params[1].Value = "MeetingId=" + id;
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procMeetingSel", Params);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public bool DeleteMeetingInfo(string date, string stime, string etime)
        {
            Params = new SqlParameter[3];

            Params[0] = new SqlParameter("@parDate", SqlDbType.VarChar, 20);
            Params[0].Value = date;

            Params[1] = new SqlParameter("@parStartTime", SqlDbType.VarChar, 20);
            Params[1].Value = stime;

            Params[2] = new SqlParameter("@parEndTime", SqlDbType.Float, 10);
            Params[2].Value = etime;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procDeleteMeetingInfo", Params);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public bool DelMeeting(int i)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@parMeetingId", SqlDbType.VarChar, 20);
            Params[0].Value = i;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procDelMeeting", Params);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public DataSet GetMeetingInfo()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetMeetingInfo", null);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public DataSet GetZipInfo()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetZipInfo", null);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public bool DelZipInfo(string zipid)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varModuleID", SqlDbType.VarChar, 20);
            Params[0].Value = zipid;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procDelZipInfo", Params);
                return true;
            }
            catch
            {
                return false;
            }

        }

        public DataSet GetUserInfo(string id)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@parFields", SqlDbType.VarChar, 400);
            Params[0].Value = "AccId,FName";

            Params[1] = new SqlParameter("@parConditions", SqlDbType.VarChar, 400);
            Params[1].Value = "AccId=" + id;
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetUserInfo", Params);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public DataSet FetchGuestEmailName(string id)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@parMeetingId", SqlDbType.VarChar, 400);
            Params[0].Value = id;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procFetchGuestEmailName", Params);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public DataSet UserReg(string id)
        {
            Params = new SqlParameter[2];

            Params[0] = new SqlParameter("@parFields", SqlDbType.VarChar, 400);
            Params[0].Value = "AccId,FName,LName,PhoneNo,ZipCode,EMail,Pass,Fax,City,CountryId,StateId";

            Params[1] = new SqlParameter("@parConditions", SqlDbType.VarChar, 400);
            Params[1].Value = "AccId=" + id;
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procUserReg", Params);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public DataSet GetAllPod()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetAllPod", null);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public DataSet GetZipModule(string id)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varModuleID", SqlDbType.VarChar, 20);
            Params[0].Value = id;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetZipModule", Params);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
            return new DataSet();
        }

        public DataSet GetDllInfo()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetDllInfo", null);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public DataSet GetClassDll(string id)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varDllID", SqlDbType.VarChar, 20);
            Params[0].Value = id;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetClassDll", Params);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public int UserValidation(string email, string password)
        {
            string[] tablename ={ "ar1" };
            Params = new SqlParameter[3];

            Params[0] = new SqlParameter("@varEmail", SqlDbType.VarChar, 200);
            Params[0].Value = email;

            Params[1] = new SqlParameter("@varPass", SqlDbType.VarChar, 200);
            Params[1].Value = password;

            Params[2] = new SqlParameter("@Result", SqlDbType.Int, 10);
            Params[2].Direction = ParameterDirection.Output;

            try
            {
                DataSet ds = SqlHelper.ExecuteDataset(conStr, CommandType.StoredProcedure, "procUserValidation", Params);

                if (Params[2].Value != DBNull.Value)
                {
                    return Convert.ToInt16(Params[2].Value);
                }
                else
                {
                    return -1;
                }
            }
            catch
            {
                //exp.Data.Add("My Key", "1videoConference--:--Database.xaml.cs--:--GuestMeetingInfo()--:--");
                // clsUtility.LogException = exp;
                return Result;
            }
        }

        public int CheckModule(string modulename)
        {
            string[] tablename ={ "ar1" };
            Params = new SqlParameter[3];

            Params[0] = new SqlParameter("@varModuleName", SqlDbType.VarChar, 200);
            Params[0].Value = modulename;

            Params[1] = new SqlParameter("@Result", SqlDbType.Int, 10);
            Params[1].Direction = ParameterDirection.Output;

            try
            {
                DataSet ds = SqlHelper.ExecuteDataset(conStr, CommandType.StoredProcedure, "procCheckModule", Params);

                if (Params[1].Value != DBNull.Value)
                {
                    return Convert.ToInt16(Params[1].Value);
                }
                else
                {
                    return -1;
                }
            }
            catch (Exception xp)
            {
                //System.Windows.MessageBox.Show(xp.Message);

                return Result;
            }
        }

        public DataSet GetModuleInfo()
        {
            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetModuleInfo", null);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public bool DelModuleInfo(string dllid)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varDllid", SqlDbType.VarChar, 200);
            Params[0].Value = dllid;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procDelModuleInfo", Params);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public DataSet EditModule(string modulename)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varModuleName", SqlDbType.VarChar, 200);
            Params[0].Value = modulename;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procEditModule", Params);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }

        public bool UpdModule(string modid, string mname, string desc, string vers)
        {
            Params = new SqlParameter[4];

            Params[0] = new SqlParameter("@varModID", SqlDbType.Int, int.MaxValue);
            Params[0].Value = modid;

            Params[1] = new SqlParameter("@varModName", SqlDbType.VarChar, 80);
            Params[1].Value = mname;

            Params[2] = new SqlParameter("@varModDesc", SqlDbType.VarChar, int.MaxValue);
            Params[2].Value = desc;

            Params[3] = new SqlParameter("@varModVers", SqlDbType.VarChar, int.MaxValue);
            Params[3].Value = vers;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procUpdModule", Params);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public DataSet GetModId(string controlname)
        {
            Params = new SqlParameter[1];

            Params[0] = new SqlParameter("@varControlName", SqlDbType.VarChar, 400);
            Params[0].Value = controlname;

            try
            {
                ds = SqlHelper.ExecuteDataset(conStr, "procGetModId", Params);
                return ds;
            }
            catch
            {
                return new DataSet();
            }
        }
    }
}
